import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/config/config.dart';
import '../../main_page/provider/bottom_bar_provider.dart';

class CommunityMainModuleLogic extends GetxController with GetTickerProviderStateMixin {
  final int defaultIndex;
  final modules = [];
  late final TabController tabController;

  CommunityMainModuleLogic(this.defaultIndex);

  @override
  void onInit() {
    super.onInit();
    modules.addAll(Config.plateModule?.community ?? []);
    tabController = TabController(length: modules.length, vsync: this, initialIndex: defaultIndex);
    tabController.addListener(() {
      if (!tabController.indexIsChanging) {
        CommunityBottomProvider().setSrollController(tabController.index);
      }
    });
  }

  void skipToTabIndex(int index) {
    tabController.index = index;
  }
}
